<?php
namespace data\service;

use data\model\Config as configModel;
use think\facade\Session;

class ConfigService extends BaseService{

    // 模型初始化
    public function __construct()
    {
        $this->model = new configModel;
    }

    /**
     * 根据分类获取配置信息
     * @date 2018-1-30
     */
    public function getConfigByType($type){
        return $this->model->where('type','=',$type)->column('key,value');
    }

    /**
     * 循环保存配置信息
     * 如果存在则修改，不存在就保存进去
     */
    public function forSaveConfig($post){
        foreach ($post as $key => $val){
            $this->model->updateConfig($key,$val);
        }
    }

    /**
     * 获取站长的信息
     * @desc
     * @author 16
     * @date 2018/2/23
     */
    public  function getAuthorInfo(){
        return configModel::where('type','=',configModel::USER_CONFIG)->column('key,value');
    }

    /**
     * 获取站点信息
     * @desc
     * @return array
     * @author 16
     * @date 2018/2/24
     */
    public  function getWebInfo(){
        return configModel::where('type','=',configModel::WEB_CONFIG)->column('key,value');
    }

}